/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.autosalon.ui.doplnek.action;

import com.autosalon.ui.doplnek.Doplnek;
import com.autosalon.ui.doplnek.state.DoplnekStateHolder;
import com.vaadin.ui.Button.ClickEvent;

/**
 * Trida pro nastaveni stavu k formulari pro novy doplnek
 * @author Petr Kriegisch
 */
public class NewDoplnekAction extends AbstractDoplneklAction {

    public NewDoplnekAction(Doplnek doplnek) {
        super(doplnek);
    }

    @Override
    public void buttonClick(ClickEvent event) {
        int id;
        try {
            id = doplnek.getSwitcher().getMainWindow().getZakaznik().getRole().getId().intValue();
        } catch (NullPointerException e) {
            id = 1;
        }
        DoplnekStateHolder.setState(DoplnekStateHolder.NEW_DOPLNEK_STATE, id, super.doplnek);
    }
}
